package MyThread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2022-12-30
 * Time: 15:13
 */
public class ThreadDemo6 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                    System.out.println("hello");
            }
        }, "mythread"); // 给线程起名字

        // t.setDaemon(true); // 将t线程设置成守护/后台线程
        // 此时, 进程的结束与否, 就与t线程无关了, main线程执行完, 整个进程就结束了
        t.start();
        while (true) {
            Thread.sleep(1000);
            System.out.println(t.isAlive());
        }
    }
}
